#ifndef __EPOLL_H__
#define __EPOLL_H__

#include "common.h"
#include <sys/epoll.h>

class EpollOpt
{
public:
	static int CreateEpoll()
	{
		return epoll_create(256);
	}

	static int AddEpoll(int epollfd, int fd, uint32_t ets, void* data)
	{
		struct epoll_event ev;
		ev.events = ets;
		ev.data.ptr = data;
		return epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev);
	}

	static int DelEpoll(int epollfd, int fd)
	{
		//Logger::info("DelEpoll FFL[%s, %s, %d] epollfd:%u, fd:%u", LOG_FFL, epollfd, fd);
		return epoll_ctl(epollfd, EPOLL_CTL_DEL, fd, nullptr);
	}

	static int ModEpoll(int epollfd, int fd, uint32_t ets, void* data)
	{
		struct epoll_event ev;
		ev.events = ets;
		ev.data.ptr = data;
		return epoll_ctl(epollfd, EPOLL_CTL_MOD, fd, &ev);
	}

	static int WaitEpoll(int epollfd, struct epoll_event* evts, int size, int timeout)
	{
		return epoll_wait(epollfd, evts, size, timeout);
	}
};


#endif
